package com.bw.contraller;

import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.bw.service.TmsService;
import com.bw.service.TmsServiceImp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @author 梁凯博
 */
@RestController
public class TmsController {
    @Autowired
    TmsService tmsService;

    @RequestMapping("/findFan")
    public Object findFan(){
        List<Map> list = tmsService.findFan();
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("status",0);
        jsonObject.put("msg","");
        jsonObject.put("data",list.get(0).get("sum(amount)"));
        return jsonObject;
    }

    @RequestMapping("/findRe")
    public Object findRe(){
        List<Map> list = tmsService.findRe();
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("status",0);
        jsonObject.put("msg","");
        JSONObject dataObject = new JSONObject();

        JSONArray mapArray = new JSONArray();
        for (Map map : list) {
            JSONObject mapObject = new JSONObject();
            mapObject.put("name","name");
            mapObject.put("value","order_no");

            mapArray.add(mapObject);
        }
        dataObject.put("mapDate",mapArray);

        return jsonObject;
    }
}
